/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.jm.financeiro.filter;

import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.HtmlEmail;

/**
 *
 * @author joao
 */
public class SendEmail {

    public SendEmail() {
        super();
    }

    public static void enviaEmailSimples(String from, String to, String subject, String message) throws EmailException {
        HtmlEmail email = new HtmlEmail();
        email.setHostName("smtp.gmail.com"); // o servidor SMTP para envio do

        // e-mail
        email.addTo(to); //destinatário
        email.setFrom("triunfosp@gmail.com", "Triunfo"); //remetente
        email.setSubject(subject); //assunto do e-mail
        email.setMsg("Teste de Email utilizando commons-email em texto"); //conteudo do e-mail

        StringBuilder conteudoEmail = new StringBuilder();
        conteudoEmail.append("");
        conteudoEmail.append("");
        conteudoEmail.append("<html><head></head><body>").append(message).append("</html></body>");
        conteudoEmail.append("");
        conteudoEmail.append("");

        //email.setMsg("Conteudo em texto");
        email.setHtmlMsg(conteudoEmail.toString());

        email.setAuthentication("triunfosp@gmail.com", "emailsdos@p");
        email.setSmtpPort(465);
        email.setSSL(true);
        email.setTLS(true);
        email.send();
    }
}
